var pid = location.search.split("?")[1].split("=")[1];
alert(pid)
$.ajax({
    url: `account/search/${pid}`
}).then(function (res) {
    //把当前数据拷贝一份,删除哪些不要的东西
    var copyeObj = Object.assign({}, res)
    delete copyeObj.bigImgs;
    delete copyeObj.middleImgs;
    delete copyeObj.smallImgs;
    //把copyeObj 保存到 当前的按钮
    $("#js_cart").attr("data-info", JSON.stringify(copyeObj))
    let strHtml = `
        <div id="box">
            <div class="middleImg">
                <img src="images/images1/1_2.jpg" />
                <div class="middleArea"></div>
            </div>
            <div class="small">
                <ul>
                    <li><img src="images/images1/1-1.jpg" /></li>
                    <li><img src="images/images1/2_1.jpg" /></li>
                    <li><img src="images/images1/3_1.jpg" /></li>
                    <li><img src="images/images1/4_1.jpg" /></li>
                    <li><img src="images/images1/5_1.jpg" /></li>
                </ul>
            </div>
            <div class="bigArea">
                <img class="bigImg" src="images/images1/1_3.jpg" />
            </div>
            <div class="logo2"><img src="./images/双11.png" alt=""></div>
            <div class="logo3"><img src="./images/Snipaste_2021-10-28_11-29-33.jpg" alt=""></div>
            <p class="txt1"> 收藏&nbsp;|&nbsp;分享</p>
        </div>



        <div class="txtlist ">
            <p class="title">Armani阿玛尼满天星镶钻星空AR1926轻奢气质石英女表佟丽娅同款</p>
            <div class="upper_xuyan">满天星璀璨镶钻星空表盘，展现女神优雅气质，选用钢和金钢混合精制而成，表盘饰以星空般的水晶点缀。蝴蝶双按扣，佩戴便捷。<span
                    class="js_more CUSTOMER-SERVICE">咨询优惠</span></div>

            <div class="upper_model clearfix">
                <div class="fl upper_model_a"><span>型号:</span><span>AR1926</span></div>
                <div class="fl upper_model_b"><span>编号:</span><span>51784</span></div>
                <div class="fl upper_model_c"><span>品牌:</span><span>阿玛尼</span></div>
                <div class="fr upper_model_d"><span>销量:</span><span>1735</span></div>
            </div>

            <div class="boximg"><img src="./images/price.jpg" alt="">

                <div class="imgbox"><img src="./images/$.jpg" alt=""></div>


            </div>
            <div class="upper_give clearfix">
                <div class="upper_give_left fl">配送</div>
                <div class="upper_give_right fl"><i>（顺丰包邮）</i> 17:30前支付，预计1-3个工作日内发货，支持货到付款 </div>
            </div>
            <div class="promise clearfix">
                <div class="left fl">承诺</div>
                <div class="right fl">
                    <li class="fl"><i></i> <span class="">正品保障</span>
                        <div class="popup" style="display: none;">全站自营直采，高于瑞士国家标准的进出仓全检机制，万表10年零假货投诉。</div>
                    </li>
                    <li class="fl"><i></i> <span class="">正规发票</span>
                        <div class="popup" style="display: none;">提供国家税务局认可的正规发票，具有售后维权法律效力。</div>
                    </li>
                    <li class="fl"><i></i> <span class="">假一赔三</span>
                        <div class="popup" style="display: none;">万表自营新表10年累计交易超50万枚腕表，正品无假货，如有售假三倍赔偿。</div>
                    </li>
                    <li class="fl"><i></i> <span class="">7天退换</span>
                        <div class="popup" style="display: none;">无理由退换：撕开贴膜及特卖、预售、定制等商品不支持；质量退换：非人为机芯故障或商品制造缺陷</div>
                    </li>
                    <li class="fl"><i></i> <span class="">全球联保</span>
                        <div class="popup" style="display: none;">800+家售后服务点，完善的售后保障，可享受品牌全球联保服务。</div>
                    </li>
                    <li class="fl"><i></i> <span class="">实体体验</span>
                        <div class="popup" style="display: none;">多家线下体验中心，互联网+新零售。</div>
                    </li>
                    <li class="fl"><i></i> <span class="">闪电发货</span>
                        <div class="popup" style="display: none;">每天17：30前下单，可当天发货。</div>
                    </li>
                    <li class="fl"><i></i> <span class="">货到付款</span>
                        <div class="popup" style="display: none;">收到货验货后再支付，可刷卡、现金、转账。</div>
                    </li>
                </div>
            </div>

            <div class="service clearfix">
                <div class="left fl">服务</div>
                <div class="right fl"> <a class="fl" href="./首页.html" target="_blank"><span>万表名匠提供全国联保</span><i
                            class="icon-d-new_choice"></i></a> <a class="fl" href="./login.html"
                        target="_blank"><span>100%正品二手表库</span><i class="icon-d-new_choice"></i></a> </div>
                <div class="servicePopup">该产品享有2年名匠保修服务</div>
            </div>

            <div class="upper_style clearfix">
                <div class="upper_style_left fl">款式</div>
                <div class="upper_style_right fl"> <a href="/goods/51783" class="fl "><span
                            class="upper_style_right_img fl"><img src="./images/dmjpg.jpg" alt=""></span> <span
                            class="upper_style_right_text fl">钢 白色 镶钻 不锈钢</span> </a> <a href="/goods/51784"
                        class="fl upper_style_right_action"><span class="upper_style_right_img fl"><img
                                src="./images/dmjpg.jpg" alt=""></span> <span class="upper_style_right_text fl">钢 白色 镶钻
                            不锈钢</span>
                        <div class="tag icon-a-o-arrow-black"></div>
                    </a> <a href="/goods/75917" class="fl "><span class="upper_style_right_img fl"><img
                                src="./images/dmjpg.jpg" alt=""></span> <span class="upper_style_right_text fl">不锈钢
                            白色</span> </a> </div>
            </div>


            <div class="upper_number clearfix">
                <div class="upper_number_left fl">数量</div>
                <div class="upper_number_right fl">
                    <div class="upper_number_right_a fl"> <span class="fl reduce" data-type="subtract">-</span> <input
                            type="text" value="1" class="cont fl" id="count" data-realcount="2" data-virtualcount="33"
                            onkeyup="this.value=this.value.replace(/[^\d]/g,'') "
                            onafterpaste="this.value=this.value.replace(/[^\d]/g,'')"> <span class="fl plus"
                            data-type="add" data-saletype="3">+</span></div>
                </div>
                <div class="upper_number_count fl">库存紧张</div>
            </div>
            <div class="upper_button clearfix">
                <div class="upper_button_a page fl js_purchase">立即购买</div>
                <a href="../src/cart/购物车2.html">
                    <div class="upper_button_b page fl" id="js_cart">加入购物车</div>
                </a>
                <div class="qr-code fl">
                    <div class="icon"> <img src="./images/ewm5.png" alt=""></div>
                    <em class="text">点击领优惠</em>
                    <div class="qr-code-popup">
                        <div class="qr-code-container first"> <img src="./images/wb.jpeg" alt="">
                            <e class="qr-code-tip">扫码下单更优惠</e>
                        </div>
                        <div class="qr-code-container second"> </div>
                    </div>
                </div>
            </div>
    `;

    $(".box").html(strHtml)
})

$(function () {
    $("#js_cart").on("click", function () {
        //    console.log( $(this).attr("data-info"));
        //$("xx").data()专门取自定义属性的值
        // console.log($(this).data("info"));

        let u_Id = JSON.parse(localStorage.getItem("userinfo") || '{}').u_id;
        let number = $("#txt").val();
        // 商品id,商品名称,商品单击,商品数量,购买人
        //购买人  利用 Object.assign  合并2个对象
        var oList = Object.assign($(this).data("info"), { u_Id, number });
        console.log(oList);

        //
        $.ajax({
            url: "/account/addCart",
            type: 'post',
            data: oList
        }).then(function (res) {
            layer.msg(res.msg);
        })
    })

})